<?php
require_once("lib/db_connection.php");
$veh = $_GET['veh'];
$discount = $_GET['discount'];
$chkLabor = $_GET['chkLabor'];
$chkParts = $_GET['chkParts'];
$chkMisc = $_GET['chkMisc'];
$misc_temp = $_GET['misc'];
$wo_id = $_GET['wo_id'];
$tax = $_GET['tax']/100;

$tax_parts = 0;
$tax_laborline = 0;
$parts_amount = 0;
$laborline_total = 0;
$misc = 0;
if($chkMisc==1)
{
$query_misc ="SELECT SUM(amount) as amount FROM veh_misc_tbl WHERE vehicle_id='".$veh."' AND workorder='".$wo_id."'";
$result_misc = mysql_query($query_misc) or die("SELECT PARTS ".mysql_error());
$row_misc = mysql_fetch_array($result_misc);

$misc_amount = $row_misc['amount'];

$tax_misc = $tax*$misc_amount;
//$misc = $misc_temp;
}
if($chkParts==1)
{
$query_parts ="SELECT SUM(amount) as amount FROM veh_parts_tbl WHERE vehicle_id='".$veh."' AND warranty='0' AND workorder='".$wo_id."'";
$result_parts = mysql_query($query_parts) or die("SELECT PARTS ".mysql_error());
$row_parts = mysql_fetch_array($result_parts);

$parts_amount = $row_parts['amount'];

$tax_parts = $tax*$parts_amount;
}

if($chkLabor==1)
{
$query_laborline ="SELECT SUM(total) as total FROM veh_laborline_tbl WHERE vehicle_id='".$veh."' AND warranty='0' AND workorder='".$wo_id."'";
$result_laborline = mysql_query($query_laborline) or die("SELECT LABORLINE ".mysql_error());
$row_laborline = mysql_fetch_array($result_laborline);

$laborline_total = $row_laborline['total'];

$tax_laborline = $tax*$laborline_total;
}

$tax = $tax_parts + $tax_laborline + $tax_misc;

$total = $parts_amount + $laborline_total + $tax_parts + $tax_laborline - $discount + $misc_amount;
$arr_string = "'$parts_amount','$laborline_total','$tax','$total','$misc_amount'";
echo "new Array($arr_string)";
?>
